package com.os.opencv.java.chapter8;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.CLAHE;
import org.opencv.imgproc.Imgproc;

public class Clahe {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //读取图像并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/Pictures/gdl.jpg", Imgcodecs.IMREAD_GRAYSCALE);
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        //直方图均衡化并在屏幕上显示结果
        Mat dst = new Mat();
        Imgproc.equalizeHist(src, dst);
        HighGui.imshow("dst", dst);
        HighGui.waitKey(0);

        //自适应直方图均衡化并在屏幕上显示结果
        CLAHE clahe = Imgproc.createCLAHE();
        clahe.apply(src, dst);
        HighGui.imshow("CLAHE", dst);
        HighGui.waitKey(0);

        System.exit(0);
    }
}
